# 设置最小 CMake 版本
cmake_minimum_required(VERSION 3.10)

# 设置项目名称
project(sdl)

# 设置 C++ 标准
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

file(GLOB FILE_SOURCES RELATIVE
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/video/cocoa/SDL_cocoawindow.m
    ${CMAKE_CURRENT_SOURCE_DIR}/video/cocoa/SDL_cocoaevents.m
    ${CMAKE_CURRENT_SOURCE_DIR}/video/cocoa/SDL_cocoamouse.m
    ${CMAKE_CURRENT_SOURCE_DIR}/video/cocoa/SDL_cocoaclipboard.m
    ${CMAKE_CURRENT_SOURCE_DIR}/video/cocoa/SDL_cocoavideo.m
    ${CMAKE_CURRENT_SOURCE_DIR}/video/cocoa/SDL_cocoamodes.m
    ${CMAKE_CURRENT_SOURCE_DIR}/video/cocoa/SDL_cocoakeyboard.m
    ${CMAKE_CURRENT_SOURCE_DIR}/video/cocoa/SDL_cocoashape.m
    #${CMAKE_CURRENT_SOURCE_DIR}/video/SDL_video.c
    #${CMAKE_CURRENT_SOURCE_DIR}/video/SDL_rect.c
    #${CMAKE_CURRENT_SOURCE_DIR}/video/SDL_pixels.c 
    #${CMAKE_CURRENT_SOURCE_DIR}/video/SDL_surface.c
    #${CMAKE_CURRENT_SOURCE_DIR}/video/SDL_RLEaccel.c
    #${CMAKE_CURRENT_SOURCE_DIR}/video/SDL_blit.c 
    ${CMAKE_CURRENT_SOURCE_DIR}/video/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/timer/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/timer/unix/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/render/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/render/software/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/thread/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/thread/pthread/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/atomic/*.c
    ${CMAKE_CURRENT_SOURCE_DIR}/events/*.c 
    ${CMAKE_CURRENT_SOURCE_DIR}/stdlib/*.c 
    ${CMAKE_CURRENT_SOURCE_DIR}/cpuinfo/*.c 
    ${CMAKE_CURRENT_SOURCE_DIR}/*.c 
)



add_library(sdl ${FILE_SOURCES})
target_compile_options(sdl PRIVATE "-fobjc-arc")

target_include_directories(sdl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)

find_library(COCOA_LIBRARY Cocoa)
find_library(QUARTZ_LIBRARY QuartzCore)
find_library(IOKit_LIBRARY IOKit)
find_library(Carbon_LIBRARY Carbon)

target_link_libraries(
    sdl
    ${COCOA_LIBRARY}
    ${QUARTZ_LIBRARY}
    ${IOKit_LIBRARY}
    ${Carbon_LIBRARY}
)